from flask import Flask,render_template,request
from flask_socketio import SocketIO,send,emit,join_room,leave_room
# from create_app import create_flask_app
# from settings.default import DefaultConfig
import eventlet
eventlet.monkey_patch()
app = Flask("chatApp",static_folder='static',template_folder='templates')
app.config['SECRET'] = 'bruh'
socketio = SocketIO(app)
@app.route('/')
def test_sconnect():
    return render_template("index.html")

@socketio.on("message")
def handleMessage(msg):
    print(f"服务器收到了:{msg}")
@socketio.event
def joinRoom(message):
    print(message)
    join_room(message['room'])
    emit('roomJoined',{
        'user':request,
        'room':message['room']
    })


if __name__ == '__main__':
    socketio.run(app,debug=True)
